import { CreateElement, VNode } from 'vue';
import { Vue, Component, Prop } from 'vue-property-decorator';

import { ClientAction } from '../../vendors/handie';

import { getActionComponent } from './helper';

@Component({
  // @ts-ignore
  abstract: true,
})
export default class ActionRenderer extends Vue {
  @Prop({ type: Object, default: null })
  private readonly action!: ClientAction;

  private render(h: CreateElement): VNode | null {
    return this.action
      ? h(getActionComponent(this.action), { props: { action: this.action } })
      : null;
  }
}
